﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KFC.MonAnF
{
    public class PhanAnTreEm : PhanAn
    {
        public PhanAnTreEm()
        {
           // MonAnFactory.add(this);
        }

        public override string LayTenLoaiDoiTuong()
        {
            return "PhanAnTreEm";
        }

        public override MonAn Clone()
        {
            MonAn monAnNew = new PhanAnTreEm();
            monAnNew.ChiTietMonAn = ChiTietMonAn;
            monAnNew.DonGia = DonGia;
            monAnNew.LoaiDoiTuong = LoaiDoiTuong;
            monAnNew.MaMonAn = MaMonAn;
            monAnNew.SoLuong = SoLuong;
            monAnNew.TenMonAn = TenMonAn;
            ((PhanAn)monAnNew).DsMaMonAnDon = new List<string>();

            foreach (var i in this.DsMaMonAnDon)
                ((PhanAn)monAnNew).DsMaMonAnDon.Add(i);

            ((PhanAn)monAnNew).DsSoLuongMon = new List<int>();

            foreach (var item in this.DsSoLuongMon)
                ((PhanAn)monAnNew).DsSoLuongMon.Add(item);

            return monAnNew;
        }

        public override void ThayDoiGiaDongBoTheoMonDon(int soTienChenhLech, string sender)
        {
            for (int i = 0; i < DsMaMonAnDon.Count; i++)
            {
                if (DsMaMonAnDon[i] == sender)
                {
                    int soTienThayDoi = soTienChenhLech * DsSoLuongMon[i];
                    DonGia += soTienThayDoi;
                    QuanLyMonAn qlma = QuanLyMonAn.Instance();
                    qlma.CapNhatGia(MaMonAn, DonGia);
                }
            }
        }
    }
}
